package com.itheima.exception;

import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@Component
@ControllerAdvice
public class ExceptionAdivce {
   @ExceptionHandler(NullPointerException.class)
   @ResponseBody
    public String doNullException(){
        System.out.println("doNullException is running...");
        return "NullPointerException";

    }
    @ExceptionHandler(ArithmeticException.class)
    @ResponseBody
    public String doArithmeticException(){
        System.out.println("ArithmeticException is running...");
        return "ArithmeticException";

    }


    @ExceptionHandler(Exception.class)
    @ResponseBody
    public String doAllException(){
        System.out.println("doAllException is running...");
        return "AllException";

    }

}
